<template>
	<view class="page1">

		<view class="new_top">
			<u-swiper :list="list5" @change="e => current = e.current" :autoplay="false"
				class="width:640px;height:312px;">
				<view slot="indicator" class="indicator">
					<view class="indicator__dot" v-for="(item, index) in list5" :key="index"
						:class="[index === current && 'indicator__dot--active']">
					</view>
				</view>
			</u-swiper>
		</view>

		<!-- <view class="one" @click="gopage"> -->
			<button v-if="!token"  class="kf_button"
				open-type="getPhoneNumber" @getphonenumber="handleCheck">
				<view class="text-wrapper_9 flex-col">
				</view>
			</button>
			<view v-else class="text-wrapper_9 flex-col" @click="handleCheck({})">
				
			</view>
			<!-- <image class="" src="https://www.ainaoxingdong.com/api/an-media/images/an/static/index/btnScreen.png"
				mode="widthFix"></image> -->
		<!-- </view> -->
		<view class="two">
			<image src="https://www.ainaoxingdong.com/api/an-media/images/an/static/index/btnNews.png" mode="widthFix">
			</image>
			<!-- <image src="../../static/index/green.gif" mode=""></image> -->
		</view>

		<tabBar></tabBar>
		<u-toast ref="uToast"></u-toast>
		
		
		<!-- 筛查结果页 -->
		<view class="header_title">
			<img src="/static/img/san.png" alt="" style="" />
			<text style="" class="text">测评得分</text>
		</view>
		<view class="box_1" v-for="(item, index) in data.detailContents" :key="index">
			<view class="algin">
				<view class="heiti" style="">
					{{ item.content }} {{ item.projectName }}
				</view>
				<view class="text" style="color: #00cc6a" v-if="item.result == '正常'">
					正常
				</view>
				<view class="text" style="color: #d96c36" v-else> 异常 </view>
			</view>
			<view class="algin">
				<view class="zhushi"> 得分：{{ item.score }} </view>
				<view class="zhushi"> 参考值：{{ item.reference }} </view>
			</view>
			<view class="zhushi"> 得分解释：{{ item.scoreExplanation }} </view>
			<view class="" style="margin: 30rpx 0">
				<u-line :dashed="index == 2"></u-line>
			</view>
		</view>
		
		<view class="header_title">
			<img src="/static/img/four.png" alt="" style="" />
			<text style="" class="text">脑健康测评数说明</text>
		</view>
		<view class="box_2">
			<view class="zhushi">
				<text>脑健康测评针对总体认知能力、主诉认知状况、记忆力、思维能力、执行功能、反应速度等领域进行评估，从而了解健康状态。</text>
			</view>
		</view>
		<view class="box_2">
			<text class="zhushi" style="color: #0ace70">主诉认知水平：</text>
			<text class="zhushi">
				是指人们主观反映自己的记忆力、注意力、思维能力、判断能力等认知功能的状况。
			</text>
		</view>
		<view class="box_2">
			<text class="zhushi" style="color: #0ace70">总体认知能力：</text>
			<text class="zhushi">
				是最基本的、经常用到的认知能力，是对记忆力、注意力、定向力、计算能力等各种能力的统称。
			</text>
		</view>
		<view class="box_2">
			<text class="zhushi" style="color: #0ace70">情景记忆：</text>
			<text class="zhushi">
				是对个人亲身经历的、发生在一定时间和地点的事件（情景）的记忆，情景记忆衰退是脑老化和痴呆相关疾病较敏感的指标。
			</text>
		</view>
		<!-- 					<view class="box_2">
					<text class="zhushi" style="color: #0ace70">执行功能：</text>
					<text class="zhushi">
						是指人脑在进行复杂的认知任务时，协调处理各个心理过程，保证个体以灵活、优化的方式实现特定目的。
					</text>
				</view> -->
		<view class="" style="margin-top: 40rpx">
			<u-line dashed></u-line>
		</view>
	</view>

</template>

<script>
	import {
		getBanner
	} from "@/api/api.js";
	import {
		is
	} from '@/config.js'
	import {
		login
	} from "@/api/api.js";
	import {
		loginlog
	} from "@/api/api.js";
	import {
		mapState
	} from "vuex";


	import {
		ref
	} from 'vue'

	export default {
		data() {
			return {
				list5: [
					'https://www.ainaoxingdong.com/api/an-media/images/an/static/index/banner1.jpg',
					'https://www.ainaoxingdong.com/api/an-media/images/an/static/index/banner2.jpg',
					'https://www.ainaoxingdong.com/api/an-media/images/an/static/index/banner3.jpg',
				],
				constants: {},
				code: '',
			}
		},
		onShow() {
			this.$store.dispatch('checkUser')
			this.getCode()
		},
		onLoad(query) {
			this.banner();
		
		
			console.log(uni.$u.mpShare, 'uni.$u.mpShare')
			uni.hideTabBar();
			// 邀请码 转码
			const scene = decodeURIComponent(query.scene);
			// promotionCode
			if (scene !== "undefined") {
				const arr = scene.split("=");
				const code = arr[arr.length - 1];
				this.$store.commit("set_promotionCode", code);
				// uni.$u.toast(code);
			} else {
				// console.log(123456789)
				this.$store.commit("set_promotionCode", '');
			}
			loginlog({}).then(
				(res) => {
					console.log(res);
				}
			);
		},
		
		methods: {
			gopage() {
				uni.navigateTo({
					url: '/pages/middleScreening/screening/screening'
				})
			},
			banner(params = {}) {
				getBanner(params).then(res => {
					console.log('res111', res)
					// const {
					// 	data
					// } = res
					// this.data = data.data || {}
					// // this.data.assessResult = 2
					// // this.data.detailContents[0].result = '异常'
					// // this.data = {}
					// console.log(data)
				})
			},
			getCode() {
				//
				const _this = this
				wx.login({
					success(res) {
						if (res.code) {
							_this.code = res.code
						} else {
							console.log("获取微信code失败！" + res.errMsg);
						}
					},
					fail(err) {
						console.log(err, "errerr");
					},
				});
			},
			redict() {
				uni.navigateTo({
					url: "/pages/middleScreening/screening/screening",
				});
			},
			handleCheck(e) {
				console.log(e, 'eeeeeeeeeeeee')
				console.log(this.token, 'this.token')
				// return
				if (this.token) {
					this.redict();
				} else {
					const _this = this
					// uni.navigateTo({
					// 	url: '/pages/personal/login/login'
					// })
					if (!e.detail.iv) {
						return
					}
			
					//发起网络请求
					login({
						encryptedData: e.detail.encryptedData,
						iv: e.detail.iv,
						code: this.code,
						promotionCode: this.$store.state.promotionCode,
					}).then(
						(res) => {
							_this.$refs.uToast.show({
								type: "success",
								message: res.msg,
							});
							// 设置vuex 和 本地缓存
							uni.setStorageSync("token", res.token);
							_this.$store.commit("set_token", res.token);
							_this.$store.dispatch('checkUser')
						},
						(err) => {
							_this.$refs.uToast.show({
								type: "error",
								message: err.msg,
							});
							_this.$store.dispatch("clearStorage");
						}
					);
				}
			},
		},
		
	}
</script>

<style scoped lang="scss">
	
	@import "./common.css";
	// @import "./index.rpx.css";
	
	.kf_button {
	
		background-color: rgba(255, 255, 255, 0);
		background: url('https://www.ainaoxingdong.com/api/an-media/images/an/static/index/btnScreen.png') center 100%/cover;
		border: 0px;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		width: 100%;
		height: 680rpx;
	}
	
	.kf_button::after {
		border: 0px;
	}
	.page1 {
		height: 100%;

		display: flex;
		align-items: center;
		flex-direction: column;
	}

	.new_top {
		width: 100%;
		height: 100%;
		// margin-top: 32px;
		padding: 32rpx 28rpx;
		// background-color: pink;
	}

	.one {
		width: 100%;
	}

	.one image {
		width: 100%;
		height: 100%;
	}

	.two {
		width: 548rpx;
		height: 168rpx;
		// width: 168rpx;
		// height: 168rpx;
		text-align: center;
	}

	.two image {
		width: 100%;
		height: 100%;
	}



	.indicator {
		@include flex(row);
		justify-content: center;



		&__dot {
			height: 6px;
			width: 6px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background-color: black;
			}
		}
	}
</style>
